package storage;

import java.awt.event.FocusEvent;
import java.awt.event.FocusListener;

import javax.swing.JCheckBox;
import javax.swing.JComboBox;
import javax.swing.JOptionPane;
import javax.swing.JTextField;

import data.ConversionTools;

public class FieldGUI {
	public JTextField nameField;
	public JTextField columnField;
	public JComboBox typeCombo;
	public JCheckBox originCheckBox;
	public JCheckBox exceptionCheckBox;
	
	public FieldGUI(){
		nameField = new JTextField();
		columnField = new JTextField();
		typeCombo = new JComboBox();
		originCheckBox = new JCheckBox("Origin");
		exceptionCheckBox = new JCheckBox("Exception");
		columnField.addFocusListener(new FocusListener(){
			@Override
			public void focusGained(FocusEvent arg0) {
			}
			@Override
			public void focusLost(FocusEvent arg0) {
				if(!columnField.getText().equals("")){
					if(!ConversionTools.isAlpha(columnField.getText())){
						JOptionPane.showMessageDialog(null, "Column must be letter(s)");
						columnField.setText("");
						columnField.requestFocus();
					}else if(columnField.getText().length()>2){
						JOptionPane.showMessageDialog(null, "Column must be less than two characters in length (ex. \"AA\")");
						columnField.requestFocus();
					}
				}
			}
		});
	}
}
